package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.source.common.config.RuoYiConfig;
import cn.source.common.utils.file.FileUploadUtils;
import cn.source.system.domain.DeyuDialysis;
import cn.source.system.domain.DeyuLogEntry;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.DeyuLogFile;
import cn.source.system.service.IDeyuLogFileService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 日志文件Controller
 *
 * @author deyucare.com
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/deyu/deyuLogFile")
public class DeyuLogFileController extends BaseController
{
    @Autowired
    private IDeyuLogFileService deyuLogFileService;

    /**
     * 查询日志文件列表
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeyuLogFile deyuLogFile)
    {
        startPage();
        List<DeyuLogFile> list = deyuLogFileService.selectDeyuLogFileList(deyuLogFile);
        return getDataTable(list);
    }

    /**
     * 获取日志文件详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(deyuLogFileService.selectDeyuLogFileById(id));
    }

    /**
     * 新增日志文件
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:add')")
    @Log(title = "日志文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeyuLogFile deyuLogFile)
    {
        return toAjax(deyuLogFileService.insertDeyuLogFile(deyuLogFile));
    }

    /**
     * 修改日志文件
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:edit')")
    @Log(title = "日志文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeyuLogFile deyuLogFile)
    {
        return toAjax(deyuLogFileService.updateDeyuLogFile(deyuLogFile));
    }

    /**
     * 删除日志文件
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:remove')")
    @Log(title = "日志文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deyuLogFileService.deleteDeyuLogFileByIds(ids));
    }

    /**
     * 导出日志文件列表
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:export')")
    @Log(title = "日志文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeyuLogFile deyuLogFile)
    {
        List<DeyuLogFile> list = deyuLogFileService.selectDeyuLogFileList(deyuLogFile);
        ExcelUtil<DeyuLogFile> util = new ExcelUtil<DeyuLogFile>(DeyuLogFile.class);
        util.exportExcel(response, list, "日志文件数据");
    }

    /**
     * 查询日志文件列表
     */
    @PreAuthorize("@ss.hasPermi('deyu:deyuLogFile:list')")
    @GetMapping("/detail")
    public TableDataInfo getLogEntries(@Validated DeyuLogEntry deyuLogEntry)
    {
        startPage();
        List<DeyuLogEntry> list = deyuLogFileService.selectByLogFileId(deyuLogEntry);
        return getDataTable(list);
    }
}
